//package test;
//
//import base.Food;
//import com.sun.lwuit.Container;
//import com.sun.lwuit.Label;
//import db.FoodManager;
//import java.util.Vector;
//import javax.microedition.midlet.MIDlet;
//
///**
// *
// * @author Shayan
// */
//public class FoodTestForm extends TestForm {
//
//    public FoodTestForm(final MIDlet parent) {
//        super(parent);
//        setTitle("Food tests");
//    }
//
//    protected TestForm getNextForm(MIDlet parent) {
//        return new IntakeTestForm(parent);
//    }
//
//    protected void runTests(Container mainContainer) throws Exception {
//        mainContainer.addComponent(new Label("f1 -----"));
//
//        Food f1 = FoodManager.getById("81E23216-022F-11DF-8E52-4AE255D89593");
//        assertFood(f1, mainContainer);
//
//        Food f2 = new Food("81E23216-022F-11DF-8E52-4AE255D89593", "Fish & chips", 100f, "BC127090-022F-11DF-A4CA-D3E355D89593");
//        FoodManager.persist(f2);
//
//        mainContainer.addComponent(new Label("f3 -----"));
//        Food f3 = FoodManager.getById("81E23216-022F-11DF-8E52-4AE255D89593");
//        assertFood(f3, mainContainer);
//
//        mainContainer.addComponent(new Label("f4 -----"));
//        Food f4 = FoodManager.getByName("Fish & chips");
//        assertFood(f4, mainContainer);
//
//        mainContainer.addComponent(new Label("ByCategory -----"));
//        Vector foods = FoodManager.getAllByCategory("BC127090-022F-11DF-A4CA-D3E355D89593");
//        mainContainer.addComponent(new Label("#" + foods.size()));
//
//        mainContainer.addComponent(new Label("f5 -----"));
//        Food f5 = (Food) foods.elementAt(0);
//        assertFood(f5, mainContainer);
//    }
//
//    private void assertFood(Food food, Container mainContainer) {
//        if (food == null) {
//            mainContainer.addComponent(new Label("Not found"));
//            return;
//        }
//
//        mainContainer.addComponent(new Label("id:" + food.getId().equalsIgnoreCase("81E23216-022F-11DF-8E52-4AE255D89593")));
//        mainContainer.addComponent(new Label("name:" + food.getName().equals("Fish & chips")));
//        mainContainer.addComponent(new Label("category:" + food.getCategoryId().equalsIgnoreCase("BC127090-022F-11DF-A4CA-D3E355D89593")));
//        mainContainer.addComponent(new Label("calories:" + (food.getCalories() == 100f)));
//    }
//}
